<?php
/**
 * Created by PhpStorm.
 * User: mars
 * Date: 2019/2/11
 * Time: 1:30 AM
 */

namespace api\controllers;


use api\models\Job;
use api\models\JobRecord;
use http\Exception\BadMessageException;
use yii\web\ServerErrorHttpException;

class JobRecordController extends BaseController
{
    public $modelClass = "api\models\JobRecord";

    public function actions()
    {
        $actions = parent::actions();
        unset($actions['delete']);

        return $actions;
    }


    public function actionDelete()
    {
        $jid   = \Yii::$app->getRequest()->getBodyParam('job_id');
        $model = JobRecord::find()->where(['jid' => $jid, 'uid' => \Yii::$app->getUser()->id])->one();
        if ($model && $model->delete()) {

            return ['msg' => '成功'];
        }
        throw new ServerErrorHttpException('Failed to delete the object for unknown reason.');
    }

}